<extend name="Base/common"/>
<block name="Content">
	<div class="am-cf am-padding-top">
        <div class="am-fl am-cf">
            <i class="am-icon-pencil-square-o"></i>
            <strong class="am-text-primary am-text-lg">
               <notempty name="workerModel">
                    编辑<else/>新增
                </notempty>小哥
            </strong>
        </div><hr data-am-widget="divider" class="am-divider am-divider-default" />
    </div>
                <form class="am-form" method="post" action="{:U('saveAction')}">
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            账号
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <input type="text" class="am-input-sm"  required
                            	name="account" value="{$workerModel['account']}" pattern="^1(3|4|5|7|8)\d{9}$"
                            	<notempty name="workerModel['account']"> readonly </notempty>>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            姓名
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" name="name" value="{$workerModel['name']}" required/>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            工号
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" name="eid" value="{$workerModel['eid']}"/>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            性别 
                        </div>
                        <div class="am-u-sm-8 am-u-md-3">
                            <input type="radio" name="sex" value="1"/>男<input type="radio" name="sex" value="2"/>女 
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            身份证号 
                        </div>
                        <div class="am-u-sm-8 am-u-md-3">
                            <input type="text" class="am-input-sm" name="id_number" value="{$workerModel['id_number']}"/>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            出生日期 
                        </div>
                        <div class="am-u-sm-8 am-u-md-3">
                            <input type="text" class="am-input-sm am-modal-prompt-input" 
		                    	data-am-datepicker="{format: 'yyyy-mm-dd'}" name="birthday" 
		                    	value="{$workerModel['birthday']|GetDateMk}" pattern="^\d{4}-\d{1,2}-\d{1,2}$"/>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            工作年限 
                        </div>
                        <div class="am-u-sm-8 am-u-md-3">
                            <input type="number" min="0" step="1" class="am-input-sm" name="work_year" 
                            	value="{$workerModel['work_year']}"/>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            职业
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                        	<select name="job" id="job"
		                    	data-am-selected="{btnSize: 'sm', btnStyle: 'secondary',maxHeight: 200}" required>
	                            <volist name=":get_dictionary_enum('job_options')" id="vo">
	  								<option value="{$key}">{$vo.enum_name}</option>
	  							</volist>
	                        </select>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            技术专长
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                        	<select name="skill[]" id="skill[]" multiple required
		                    	data-am-selected="{btnSize: 'sm', btnStyle: 'secondary',maxHeight: 200}" minchecked="1">
	                            <volist name=":get_dictionary_enum('profession_options')" id="vo">
	  								<option value="{$key}"
	  									<in name="key" value="$workerModel['profession']">selected</in>>{$vo.enum_name}</option>
	  							</volist>
	                        </select>
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">
                        </div>
                    </div>
                    <!-- 0:禁止登录；1：正常；2：闲散小哥新注册，待完善信息；；3：闲散小哥已完善信息，待审核状态；
                    4：客服审核通过，已给闲散小哥发送短信通知，待培训状态（培训通过并修改所属站点后即变成 status = 1 正常状态；5.后台新增自有团队成员初始状态；-->
                    <if condition="$workerModel.status eq '3'">
                        <div class="am-g am-margin-top">
	                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
	                            培训地点
	                        </div>
	                        <div class="am-u-sm-8 am-u-md-4">
		                        <select name="training_id" 
		                        	data-am-selected="{btnSize: 'sm', maxHeight: 200, searchBox:1}">
	                                <foreach name="trainingList" item="training">
	                                    <option value="{$training.training_id}">{$training.name}</option>
	                                </foreach>
	                            </select>
	                        </div>
	                        <div class="am-hide-sm-only am-u-md-6">
	                        </div>
	                    </div>
                        <div class="am-g am-margin-top">
	                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
	                            培训时间
	                        </div>
	                        <div class="am-u-sm-8 am-u-md-4">
	                        	<div class="am-input-group date form_datetime-1"
			                    	 data-date="" data-date-format="yyyy-mm-dd hh:ii">
	  								<input size="16" type="text" class="am-form-field" pattern="^\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}$"
	  								 	name="training_time" id="training_time" value="{$workerModel['training_time']|date='Y-m-d H:i', ###}">
	  								<span class="am-input-group-label add-on"><i class="icon-th am-icon-calendar"></i></span>
								</div>
	                        </div>
	                        
	                        <div class="am-hide-sm-only am-u-md-6">
	                        </div>
	                    </div>
                    <elseif condition="$workerModel.status neq '2'"/>		
	                    <div class="am-g am-margin-top">
	                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
	                            所在站点
	                        </div>
	                        <div class="am-u-sm-8 am-u-md-4">
		                        <select name="site_id" data-am-selected="{btnSize: 'sm', maxHeight: 200, searchBox:1}" required>
	                                <foreach name="siteList" item="site">
	                                    <option value="{$site.site_id}">{$site.site_name}</option>
	                                </foreach>
	                            </select>
	                        </div>
	                        <div class="am-hide-sm-only am-u-md-6">
	                        </div>
	                    </div>
                    </if>
                    
                    <div class="am-g am-margin-top">
		                <div class="am-u-sm-4 am-u-md-2 am-text-right">
		                    小哥简介
		                </div>
		                <div class="am-u-sm-8 am-u-md-8">
		                    <textarea rows="8" name="description" id="description" class="am-input-sm" 
		                    	required>{$workerModel['description']}</textarea>
		                </div>
		                <div class="am-hide-sm-only am-u-md-2">
		                </div>
		            </div>
                    
                    <div class="am-g am-margin-top-sm">
                		<div class="am-u-sm-4 am-u-md-2 am-text-right">
                    头像
                		</div>
                		<div class="am-u-sm-8 am-u-md-3 am-u-end">
                    		<div class="am-form-group am-form-file">
                        		<input type="file" name="pict_cover" id="pict_cover"/>
								<input type="hidden" name="att_id" id="att_id" value="{$workerModel['att_id']}"/>
                    		</div>
                    		<div id="photo_thumbnail">
		                        <notempty name="workerModel['att_id']">
		                            <figure class="am-thumbnail">
		                            	<img src="{$workerModel['fullpath']}">
		                            </figure>
		                        </notempty>
		                    </div>
                		</div>
            		</div>
                    
                    <div class="am-margin">
                        <button type="submit" class="am-btn am-btn-success am-btn-xs ajax-post" target-form="am-form">
                            提交保存
                        </button>
                        <button type="button" class="am-btn am-btn-secondary am-btn-xs" onclick="javascript:history.back(-1);return false;">
                            返回列表
                        </button>
                        <input type="hidden" name="worker_id" value="{$workerModel['worker_id']}"/>
                        <!-- 后台新增自有团队成员时，初始状态为 5，待小哥使用手机端注册后变为 1正常状态 -->
                        <input type="hidden" name="status" value="{$workerModel['status']|default='5'}"/>
                    </div>
                </form>
    </div>
</block>

<block name="script">
<script src="__PUBLIC__/Common/js/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/Common/js/amazeui.datetimepicker.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/Common/js/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__PUBLIC__/Common/js/ueditor/ueditor.all.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/Common/js/ueditor/lang/zh-cn/zh-cn.js" type="text/javascript"></script>
<script type="text/javascript">
Think.setValue('sex',{$workerModel.sex|default=1});
Think.setValue('job',{$workerModel.job|default=1});
Think.setValue('site_id',{$workerModel.site_id|default=1});

UE.getEditor("description",{
    toolbars:[[
    "fullscreen", '|', 'undo', 'redo', "|","bold", "italic", "underline", 'fontborder', 
    'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch',
    'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 
    'insertunorderedlist', 'selectall', 'cleardoc', "|", 
    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
    'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
    'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', 'insertimage']],
    wordCount:false,enableAutoSave:false,elementPathEnabled:false
});

var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);

$('#training_time').datetimepicker({
    language: 'zh-CN',
    pickerPosition: 'top-right',
    startDate: now
})

//上传图片
/* 初始化上传插件 */
$("#pict_cover").uploadify({
    "height": 30,
    "width": 120,
    "swf": "__PUBLIC__/Common/js/uploadify/uploadify.swf",
    "fileObjName": "download",
    "buttonText": "上传头像",
    "uploader": "{:U('Attachment/uploadPhoto',array('session_id'=>session_id()))}",
    "fileSizeLimit":'{$fileSize}B',
    'fileTypeExts': '*.jpg; *.png; *.gif',
    "onUploadSuccess": uploadPicture,
    "onSelectError":uploadify_onSelectError,
    "onUploadError":uploadify_onUploadError,
    'onFallback': function(){
        alert('未检测到兼容版本的Flash.');
    }
});

function uploadPicture(file, data){
	
    var data = $.parseJSON(data);
    var src = '';
    
    if (data.status) {
        $("#att_id").val(data.att_id);
        src = data.fullpath;
        $("#photo_thumbnail").html('<figure class="am-thumbnail"><img src="' + src + '"/></figure>');
    }else {
        updateAlert(data.info);
        setTimeout(function(){
            $('#top-alert').find('button').click();
            $(that).removeClass('disabled').prop('disabled', false);
        }, 1500);
    }
}


</script>

</block>